package demo;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.EmptyBorder;

public class JTabbedPaneDemo extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JTabbedPaneDemo frame = new JTabbedPaneDemo();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public JTabbedPaneDemo() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		JTabbedPane jtp = new JTabbedPane(JTabbedPane.TOP );
		JPanel jp1 = new JPanel(new BorderLayout());
		jp1.add(new JLabel("标签1"), BorderLayout.EAST);
		jp1.add(new JLabel("标签2"), BorderLayout.WEST);
		jp1.add(new JLabel("标签3"), BorderLayout.NORTH);
		jp1.add(new JLabel("标签4"), BorderLayout.CENTER);
		jp1.add(new JLabel("标签5"), BorderLayout.SOUTH);
		JPanel jp2 = new JPanel(new FlowLayout());
		for (int i = 0; i < 9; i++) {
			JButton but = new JButton("按钮"+i);
			
			jp2.add(but);
				
		}
		/*jtp.addTab("标签", jp1);
		jtp.addTab("面板", jp2);*/
		jtp.add("标签", jp1);
		jtp.add("面板", jp2);
		contentPane.add(jtp);
		setContentPane(contentPane);
	}

}
